import java.util.Arrays;

// https://leetcode-cn.com/problems/assign-cookies/
// 455. 分发饼干

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);

        int count = 0;
        int index = s.length - 1;

        for (int i = g.length - 1; i >= 0; i--) {
            if (index >= 0 && s[index] >= g[i]) {
                index--;
                count++;
            }
        }

        return count;
    }
}